package com.xquant.pricing.pricingConfig.service.impl;

import com.xquant.pricing.calc.entity.ProductTypeEnum;
import com.xquant.pricing.pricingConfig.mapper.PricingConfigAuthorMapper;
import com.xquant.pricing.pricingConfig.service.PricingConfigAuthorServiceAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * @Auther: B946
 * @Date: 23/04/2020 10:14
 * @Description:
 */
@Component
@Transactional
public class PricingConfigAuthor4OptionServiceImpl extends PricingConfigAuthorServiceAdapter {


    @Autowired
    private PricingConfigAuthorMapper pricingConfigAuthorMapper;

    @Override
    public String[] getSupportedProductTypes() {
        return new String[]{
                ProductTypeEnum.OTC_OPTION.getCode()
        };
    }

    @Override
    public void deletePricingConfig(Map<String, Object> params) {
        //删除定价配置下的期权合约配置
        pricingConfigAuthorMapper.deletePricOptionContract(params);
        //删除关联期权标的定价配置
        pricingConfigAuthorMapper.deletePricOptionUnderlying(params);
        //删除期权标的相关性配置
        pricingConfigAuthorMapper.deletePricOptionUnderlyingCorr(params);
        //删除用户定价配置权限
        pricingConfigAuthorMapper.deleteSysUserPricCfg(params);
        //删除定价配置
        pricingConfigAuthorMapper.deletePricingConfig(params);
    }

    @Override
    public void deletePricingConfigSyncAuthor(Map<String, Object> params) {
        pricingConfigAuthorMapper.deletePricOptionContract(params);
        pricingConfigAuthorMapper.deletePricOptionUnderlying(params);
        pricingConfigAuthorMapper.deletePricOptionUnderlyingCorr(params);
    }

    @Override
    public void savePricingConfigSyncAuthor(Map<String, Object> params) {
        pricingConfigAuthorMapper.insertSyncPricOptionContract(params);
        pricingConfigAuthorMapper.insertSyncOptionUnderlying(params);
    }

}
